package com.cyjt.operation.adapter;

import java.util.List;

import com.cyjt.operation.R;
import com.cyjt.operation.adapter.StaticNodesStatusAdapter.ViewHolder;
import com.cyjt.operation.bean.StaticNodesItemInfo;

import android.app.Activity;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class StaticNodesItemAdapter extends BaseAdapter {
	private List<StaticNodesItemInfo> staticNodesItem;
	private Activity activity;
	private Handler handler;

	public StaticNodesItemAdapter() {

	}

	public StaticNodesItemAdapter(Handler handler,List<StaticNodesItemInfo> staticNodesItem,
			Activity activity) {
		this.handler = handler;
		this.staticNodesItem = staticNodesItem;
		this.activity = activity;
	}

	@Override
	public int getCount() {
		return staticNodesItem.size();
	}

	@Override
	public Object getItem(int position) {
		return staticNodesItem.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public class ViewHolder {
		private TextView activity_static_node_code, activity_static_node_time;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = LayoutInflater.from(activity);
		ViewHolder viewHolder = null;
		if (convertView == null) {
			convertView = inflater.inflate(
					R.layout.adapter_staticnode_list_item_layout, null);
			viewHolder = new ViewHolder();
			viewHolder.activity_static_node_code = (TextView) convertView
					.findViewById(R.id.activity_static_node_code);
			viewHolder.activity_static_node_time = (TextView) convertView
					.findViewById(R.id.activity_static_node_time);
			convertView.setTag(viewHolder);
		} else
			viewHolder = (ViewHolder) convertView.getTag();
		StaticNodesItemInfo staticNodesItemInfo = staticNodesItem.get(position);
		viewHolder.activity_static_node_code.setText(staticNodesItemInfo
				.getContent());
		viewHolder.activity_static_node_time.setText(staticNodesItemInfo
				.getReceiveAt());
		return convertView;
	}

}
